class Solution(object):
    def hIndex(self, citations):
        """
        :type citations: List[int]
        :rtype: int
        """
        best = 0
        begin = 0
        end = len(citations)-1
        while begin<=end:
            mid = (begin+end)//2
            cita = citations[mid]
            num = len(citations)-mid
            if cita>num:
                end = mid-1
            elif cita<num:
                begin = mid+1
            else:
                best = max(best, cita)
                break
            b = min(cita, num)
            best = max(best, b)
        return best

print(Solution().hIndex([1,1]))